package com.cidp.system.service.impl;

import com.cidp.system.dao.IRoleDao;
import com.cidp.system.model.ToperatorDetail;
import com.cidp.system.model.Trole;
import com.cidp.system.service.IRoleService;
import com.litt.core.common.Utility;
import com.litt.core.exception.BusiException;
import com.litt.core.page.IPageList;
import com.litt.core.page.PagePoParam;
/**
 * <b>标题：</b>角色管理Service实现类.
 * <pre><b>描述</b>
 *    操作员管理
 * </pre>
 * 
 * @author zhanglei
 * @since 2008-5-23
 * @version 1.0
 */
public class RoleServiceImpl implements IRoleService {

	private IRoleDao roleDao;
	public void setRoleDao(IRoleDao roleDao) {
		this.roleDao = roleDao;
	}
	/**
     * 根据对象删除
     * @param Trole 对象
     */
	public void delete(Trole obj) throws BusiException {
		roleDao.deleteObject(obj);
	}

	public void deleteStatus(Long roId) throws BusiException {
		roleDao.deleteStatus(roId);
	}
	/**
	 * 读取操作员详细信息
	 * @param roId 序号
	 * @return Trole对象
	 */
	public Trole load(Long roId) throws BusiException {
		if(roId==null && Utility.isEmpty(roId.toString())){
			throw new BusiException("序号为空字段！");
		}
		return (Trole)roleDao.loadObject(Trole.class, roId);
	}

	/**
	 * 不可改变状态
	 * 
	 * @param roId
	 */
	public void nochangeStatus(Long roId) throws BusiException {
		if(roId==null && Utility.isEmpty(roId.toString())){
			throw new BusiException("序号为空字段！");
		}
		roleDao.nochangeStatus(roId);

	}

	public void resumeStatus(Long roId) throws BusiException {
		if(roId==null && Utility.isEmpty(roId.toString())){
			throw new BusiException("序号为空字段！");
		}
		roleDao.resumeStatus(roId);

	}
	  /**
     *  保存对象
     *  
     *  @param Trole 对象
     *  @return Long 主键
     */
	public Long save(Trole obj) throws BusiException {
		if(obj.getRoleName()==null || Utility.isEmpty(obj.getRoleName())){
			throw new BusiException("角色名不能为空！");
		}
		return roleDao.saveObject(obj);
	}
    /**
     *  更新记录
     *  
     *  @param Trole 对象
     */
	public void update(Trole obj) throws BusiException {
		if(obj.getRoleName()==null || Utility.isEmpty(obj.getRoleName())){
			throw new BusiException("角色名不能为空！");
		}
		roleDao.updateObject(obj);

	}
	/**
	 * 删除记录
	 */
	public void deleteById(Long id)throws BusiException{
		Trole role=this.load(id);
		roleDao.deleteObject(role);
	}
	
	public IPageList listByPage(PagePoParam pagePoParam) throws BusiException
	{
		return roleDao.listByPage(pagePoParam);
	}

}
